/*
 * xpdbg.h
 *
 *  Created on: Dec 2, 2009
 *      Author: lxb
 */

#ifndef _XPDBG_H_INCLUDED_
#define _XPDBG_H_INCLUDED_

#ifdef __cplusplus
extern "C" {
#endif

/******************************************************************************
 * <Includes>
 *****************************************************************************/

/******************************************************************************
 * <Defines>
 *****************************************************************************/

//#if (XPDEBUG==1)
#if 1
/**
 * A flag that enables/disables the debug mode
 */
#define XPDBG
#else //
#undef  XPDBG
#endif //

#ifdef  XPDBG
#include <xpos.h>
#include <stdio.h>


/**
 * Debugging macro that prints in the standard output
 * when debug mode is enabled (XPDBG == 1)
 */
#define XPPRINT(S...) printf(S)

/**
 * Debugging macro that asserts and prints the line number and filename
 * containing the failed condition when debug mode is enabled
 * (XPDBG == 1)
 */
#define XPASSERT(x) \
    { \
        if ((x) == 0) \
        { \
            printf("---ASSERT--- at line %d in %s!\n", __LINE__, __FILE__); \
            while (1) \
                { \
                    xpos_threaddelay(100 * 1000); \
                } \
        } \
    }

/**
 * Debugging macro that prints the filename, function name, and line number
 * in the standard output when debug mode is enabled (XPDBG ==
 * 1)
 */
#define XPPRINT_POS(S...) \
    { \
        printf("[iwwc] %s : Line[%u], [%s]\n", \
            __FILE__, \
            __LINE__, \
            __FUNCTION__); \
            printf(## S); \
    }



#else // XPDBG

/**
 * Debugging macro that prints in the standard output when debug mode is
 * enabled (XPDBG == 1)
 */
#define XPPRINT(S...)

/**
 * Debugging macro that asserts and prints the line number and filename
 * containing the failed condition when debug mode is enabled
 * (XPDBG == 1)
 */
#define XPASSERT(x)

/**
 * Debugging macro that prints the filename, function name, and line number
 * in the standard output when debug mode is enabled (XPDBG ==
 * 1)
 */
#define XPPRINT_POS(S...)
#endif //XPDBG

/******************************************************************************
* <temp define>
 *****************************************************************************/


/******************************************************************************
 * <Enums>
 *****************************************************************************/

/******************************************************************************
 * <Typedefs>
 *****************************************************************************/

/******************************************************************************
 * <API declarations>
 *****************************************************************************/

#ifdef __cplusplus
}
#endif

#endif /* _WDEBUG_H_INCLUDED_ */

